<!DOCTYPE html>
<html >
    <head>
        <meta charset="UTF-8">
        <title>id</title>
        <link type="text/css" rel="stylesheet" href='../../css/c1.css'>
        <style>
            *{
                margin: 0 auto;
                padding: 0;
            }
            p{
                padding: 5px 10px;
            }
        </style>
        <script src="../../work/jquery-1.12.4.min.js"></script>
        <script>
            jQuery(function ($) {
                $("#btn1",".code").click(function () {
                    $("#myDiv").css({backgroundColor:'red'});
                });
            });
        </script>

    </head>
    <body>
        <div class="title">#id</div>
        <p>根据给定的ID匹配一个元素。</p>
        <p>如果选择器中包含特殊字符，可以用两个斜杠转义。</p>
        <div class="title">代码示例</div>
        <div class="code">
            <pre>
                &lt;script&gt;
                    jQuery(function ($) {
                        $("#btn1",".code").click(function () {
                            $("<span>#myDiv</span>").css({backgroundColor:'red'});
                         });
                    });
               &lt;/script&gt;

                &lt;div id="notMe"&gt;&lt;p&gt;id="notMe"&lt;/p&gt;&lt;/div&gt;
                &lt;div id="myDiv"&gt;id="myDiv"&lt;/div&gt;

            </pre>
        </div>
        <div class="title">代码示例</div>
        <div class="code">
            <div id="notMe"><p>id="notMe"</p></div>
            <div id="myDiv">id="myDiv"</div>
            <button id="btn1" style="margin: 10px;">点击查看效果</button>
        </div>
    </body>
</html>